//
//  CalenderViewController.m
//  Findif
//
//  Created by Mac on 2018/11/22.
//  Copyright © 2018年 Cicel Chen. All rights reserved.
//

#import "CalenderViewController.h"
#import "LXCalender.h"

@interface CalenderViewController ()

@property(nonatomic,strong)LXCalendarView *calenderView;

@end

@implementation CalenderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor whiteColor];
    
    self.title = @"选择日期";
    
//    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back(1)"] style:UIBarButtonItemStylePlain target:nil action:nil];
//    
//    self.navigationItem.backBarButtonItem = backItem;
    
    self.calenderView =[[LXCalendarView alloc]initWithFrame:self.view.bounds];
    
    self.calenderView.currentMonthTitleColor =[UIColor hexStringToColor:@"2c2c2c"];
    self.calenderView.lastMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    self.calenderView.nextMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    self.calenderView.weekArray = self.weekdayArray;
    self.calenderView.dataStr = self.dateStr;
    
    self.calenderView.isHaveAnimation = YES;
    
    self.calenderView.isCanScroll = YES;
    
    self.calenderView.isShowLastAndNextBtn = YES;
    
    self.calenderView.isShowLastAndNextDate = NO;
    //53d499
    self.calenderView.todayTitleColor =[UIColor hexStringToColor:@"53d499"];
    
//    self.calenderView.selectBackColor =[UIColor blueColor];
    
    self.calenderView.backgroundColor =[UIColor whiteColor];
    
    
    [self.calenderView dealData];
    
    [self.view addSubview:self.calenderView];
    
    WeakSelf(weakSelf);
    
    self.calenderView.selectBlock = ^(NSInteger year, NSInteger month, NSInteger day) {

        NSString * dateStr = [NSString stringWithFormat:@"%ld-%ld-%ld",year,month,day];
        if (weakSelf.calenderViewControllerDelegate && [weakSelf.calenderViewControllerDelegate respondsToSelector:@selector(clickDateButton:)])
        {
            [weakSelf.calenderViewControllerDelegate clickDateButton:dateStr];
        }
        
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };
}


@end
